/*
 * BZombieMovStrategy.cpp
 *
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses 
 */

#include "BZombieMovStrategy.h"
#include "ModelConstants.h"

void BZombieMovStrategy::resolveMoveDirection(Map& map) {
    int chased_bomberman_direction = zombie->scoutForBomberman(map);
    if (chased_bomberman_direction != NO_DIRECTION) {
        // It always chase a bomberman if one is on sight
        zombie->setDirection(chased_bomberman_direction);
        return;
    }
    // If it's going to colide, it changes direction
    if (map.tileIsOccupied(zombie->getNextX(), zombie->getNextY())) {
        zombie->setDirection(zombie->getRandomDirection());
    }
}

void BZombieMovStrategy::resolveInvalidMove(Map& map) {
    zombie->setDirection(zombie->getRandomDirection());
}
